package com.designed.pattern.creational.singleton.doubleChecked;

import java.io.Serializable;

/**
 * @author yifei
 * @date 2024/3/28
 **/
public class DoubleCheckSingleton implements Serializable {
    private static DoubleCheckSingleton doubleCheckSingleton = null;
    private DoubleCheckSingleton(){}

    private static DoubleCheckSingleton getInstance(){
        if(doubleCheckSingleton==null){
            synchronized(DoubleCheckSingleton.class){
                if(doubleCheckSingleton==null){
                    doubleCheckSingleton = new DoubleCheckSingleton();
                }
            }
        }
        return doubleCheckSingleton;
    }

    private Object readResolve(){
        return doubleCheckSingleton;
    }

}
